Backport path_startswith_full()
authorArnaud Rebillout <arnaudr@debian.org>
Mon, 6 Apr 2026 11:17:22 +0000 (18:17 +0700)
committerArnaud Rebillout <arnaudr@debian.org>
Mon, 13 Apr 2026 07:18:40 +0000 (14:18 +0700)
commitd2f89c9b0843a2ade1242dd369016ec2cfe24d06
treedb3a0e6d19e42fb3e3a466ada353d09cab2f66b2
parent31645c408e64d16529e974e363f804b2451a64be
Backport path_startswith_full()

This is a prerequisite to fix CVE-2026-29111.

path_startswith_full() was introduced in systemd v249, in commit 63f11e354a3:
"path-util: use path_find_first_component() in path_startswith()".

Looking at the commit, we can see that the existing path_startswith() function
became a special-case of path_startswith_full(), but there's more to it.
path_startswith_full() is also a complete rewrite of the original
path_startswith(), and the commit message mentions that the new implementation
is stricter.

To avoid surprises and potential regressions, this commit opts for a
conservative approach: we don't touch the existing path_startswith() function,
and we add path_startswith_full() as a entirely new function.

Note that it's enough for our purpose: the fix for CVE-2026-29111 makes use of
path_startswith_full().

path_startswith_full() was updated after it was introduced in v249: indeed, it
was extended to address CVE-2026-29111, and the change was backported to v257.
Therefore, this commits takes the function (and associated unit tests) from the
v257 branch.

Forwarded: not-needed

Gbp-Pq: Name CVE-2026-29111-2.patch
src/basic/path-util.c
src/basic/path-util.h
src/test/test-path-util.c